<?php

namespace App\Ship\Criterias;

use App\Ship\Parents\Criterias\Criteria;
use Prettus\Repository\Contracts\RepositoryInterface as PrettusRepositoryInterface;

/**
 * Class ThisProjectCriteria.
 *
 * @author  Mahmoud Zalt <mahmoud@zalt.me>
 */
class ThisProjectCriteria extends Criteria
{
    /**
     * @var int
     */
    private $projectId;

    /**
     * ThisProjectCriteria constructor.
     *
     * @param $projectId
     */
    public function __construct($projectId = null)
    {
        $this->projectId = $projectId;
    }

    /**
     * @param                                                   $model
     * @param PrettusRepositoryInterface $repository
     *
     * @return mixed
     */
    public function apply($model, PrettusRepositoryInterface $repository)
    {
        return $model->where('project_id', '=', $this->projectId);
    }
}
